/*!
 * @file point2f.cpp
 * @brief Ciało point2f.hh
 */

#include "engine/basic/point2f.hh"
using namespace std;

/*--------------------------------------------------------------------------*/

point2f::point2f() :
	x(), y() {

}

/*--------------------------------------------------------------------------*/

point2f::point2f(int x, int y) :
	x(x), y(y) {
}

/*--------------------------------------------------------------------------*/

void point2f::normalize() {
	float length = sqrt(x * x + y * y);

	x = x / length;
	y = y / length;
}

/*--------------------------------------------------------------------------*/

float point2f::length() {
	return sqrt(x * x + y * y);
}

/*--------------------------------------------------------------------------*/

ostream & operator <<(ostream & out, point2f & val) {
	out << "(" << val.x << "; " << val.y << ")" << endl;
	return out;
}

/*--------------------------------------------------------------------------*/

point2f operator +(point2f p1, point2f p2) {
	return point2f(p1.x + p2.x, p1.y + p2.y);
}

/*--------------------------------------------------------------------------*/

point2f operator -(point2f p1, point2f p2) {
	return point2f(p1.x - p2.x, p1.y - p2.y);
}

/*--------------------------------------------------------------------------*/

point2f operator /(point2f v, float what) {
	return point2f(v.x / what, v.y / what);
}

/*--------------------------------------------------------------------------*/
